package bocchi.card;

import bocchi.base.BaseCustomCard;
import bocchi.base.BaseCustomPower;
import bocchi.general.Util;
import com.megacrit.cardcrawl.actions.common.GainBlockAction;
import com.megacrit.cardcrawl.actions.common.RemoveSpecificPowerAction;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.AbstractPower;
import com.megacrit.cardcrawl.powers.BarricadePower;

public class MangoKamen extends BaseCustomCard {
    private static final String RAW_ID = MangoKamen.class.getSimpleName();
    public static final String GAME_ID = RAW_ID;

    public MangoKamen() {
        super(RAW_ID);
    }

    @Override
    public void use(AbstractPlayer player, AbstractMonster monster) {
        AbstractPower power = new BaseCustomPower(RAW_ID, AbstractPower.PowerType.BUFF, player) {
            @Override
            public void updateDescription() {
                description = descriptions[0];
            }

            @Override
            public int onAttacked(DamageInfo info, int damageAmount) {
                if (owner.currentBlock <= 0) {
                    AbstractPower barricade = owner.getPower(BarricadePower.POWER_ID);
                    if (barricade != null) {
                        addToTop(new RemoveSpecificPowerAction(owner, owner, barricade));
                    }
                    addToTop(new RemoveSpecificPowerAction(owner, owner, this));
                }
                return damageAmount;
            }
        };

        addToBot(new GainBlockAction(player, player, block));
        Util.applyPower(player, player, new BarricadePower(player));
        Util.applyPower(player, player, power);
    }
}
